package com.huangliusong.desigin.pattern.behavioral.interator;

import java.util.List;

/**
 * @author huangliusong
 * @since 2018/10/13
 * {@link CourseIterator}
 */
public class CourseIteratorImpl implements CourseIterator {
    private List courseList;
    int position;
    Course course;

    public CourseIteratorImpl(List courseList) {
        this.courseList = courseList;
    }

    public Course nextCourse() {
        System.out.println("返回的课程  位置hi："+position);
        course=(Course)courseList.get(position);
        position++;

        return course;
    }

    public boolean isLastCourse() {
        if (position<courseList.size()){
            return false;
        }
        return true;
    }
}
